package CtrLayer;

import java.util.ArrayList;

import DataLayer.DB.DBService;
import DataLayer.Model.Service;

/**
 * ServiceCtr is a CRUD of service.
 * 
 * @author Gruppe 4 - Dennis Biil, Brian Smed, Kristian Henriksen og Anders Engbo
 * @version 1.0
 */
public class ServiceCtr implements IFServiceCtr
{
	public ServiceCtr()
	{
	}

	public ArrayList<Service> getAllServicer(boolean synlig)
	{
		DBService dbS = new DBService();
		return dbS.getAllService(synlig);
	}

	public ArrayList<Service> searchServiceViaSpil(String spil, boolean synlig)
	{
		DBService dbS = new DBService();
		return dbS.searchServiceViaSpil(spil, synlig);
	}

	public ArrayList<Service> searchServiceViaModel(String model, boolean synlig)
	{
		DBService dbS = new DBService();
		return dbS.searchServiceViaModel(model, synlig);
	}

	public Service getService(int serviceId)
	{
		DBService dbS = new DBService();
		return dbS.getService(serviceId);
	}

	public void createService(
								String spil, String model, String malestandard,
								double pris, boolean synlig) throws Exception
	{
		DBService dbS = new DBService();
		Service s = new Service(spil, model, malestandard, pris, synlig);
		dbS.insertService(s);
	}

	public int updateService(Service s)
	{
		DBService dbS = new DBService();
		return dbS.updateService(s);
	}

	public int deleteService(Service s)
	{
		DBService dbS = new DBService();
		return dbS.deleteService(s.getServiceId());
	}
}